package pers.tz.题目.排序;

import static pers.tz.common.SortUtils.*;

/**
 * @author irony
 * @date 2024-03-09
 */
public class 冒泡排序 {
    public static void main(String[] args) {
        int[] ints = generateRandomArray(100000);

        printArrayTime(() -> bubbleSort(ints), ints, false);
    }

    /**
     * 冒泡排序
     */
    public static void bubbleSort(int[] ints) {
        for (int i = 0; i < ints.length; i++) {
            for (int j = i + 1; j < ints.length; j++) {
                if (ints[j] <= ints[i]) {
                    int temp = ints[j];
                    ints[j] = ints[i];
                    ints[i] = temp;
                }
            }
        }
    }
}
